package servletsAction;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.ContatoDAO;


public class BuscaContato extends HttpServlet {
	private static final long serialVersionUID = 1L;
  
    public BuscaContato() {
       
    }

	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String id = request.getParameter("nome");
		String opcao = request.getParameter("opcao");
		ContatoDAO contatoDAO = new ContatoDAO();
		if(id.trim().equals("")||opcao.trim().equals("")){
			RequestDispatcher view = request.getRequestDispatcher("erroCadastro.html");
	        
	        view.forward(request, response);
	        return;
		}
		
		contatoDAO.setId(id);
		contatoDAO.setOpcao(opcao);
		
		 
		request.getSession().setAttribute("dao", contatoDAO);
			
	    RequestDispatcher view = request.getRequestDispatcher("/buscaEspecifica.jsp");
	                                                     
	    view.forward(request, response);
		
	}

}
